﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dhSystemBLL.orderData;
using baseSet.importExport;
using baseSet;
using dhDataAcess.baseBLL;

namespace dhsystem.produceForm
{
    public partial class FrmcgddMark : Form
    {
        public string pname { get; set; }
        string tablename;
        string field;
        public FrmcgddMark(string _tablenam, string _field)
        {
            InitializeComponent();
            tablename = _tablenam;
            field = _field;
        }

        private void dGridslect_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void bindingSourceselect_CurrentChanged(object sender, EventArgs e)
        {

        }

        private void comboBoxcustName_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void buttexit_Click(object sender, EventArgs e)
        {

        }

        private void buttenter_Click(object sender, EventArgs e)
        {
            try
            {
                pname = dGridslect.CurrentRow.Cells[field].Value.ToString();
                if (field != "")
                {
                    pname = dGridslect.CurrentRow.Cells[field].Value.ToString();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("选择正确的名称");
            }
        }

        private void buttonQuery_Click(object sender, EventArgs e)
        {
            bindingSourceselect.DataSource = basicSql.getmaterialList("%" + comboBoxcustName.Text + "%", "%" + textPnameQuery.Text + "%", "%" + textBox1.Text + "%","%" + textBox2.Text+"%");
            dGridslect.DataSource = bindingSourceselect;
            DcolumnSet.colSet(moduleInfo.materialList , dGridslect);
            GlobalInfo.address = comboBoxcustName.Text;
            GlobalInfo.custPO = textPnameQuery.Text;
            GlobalInfo.hetongNo = textBox1.Text;
            GlobalInfo.matName = textBox2.Text;
        }

        private void textPnameQuery_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void bindingSourcecustList_CurrentChanged(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void FrmcgddMark_Load(object sender, EventArgs e)
        {
            supplierListBLL supplier = new supplierListBLL();
            bindingSourcecustList.DataSource = supplier.GetDatasupplierListBysTypeNo();
            comboBoxcustName.DataSource = bindingSourcecustList;
            comboBoxcustName.DisplayMember = "mark";
            comboBoxcustName.ValueMember = "sNum";
            //bindingSourceselect.DataSource = packStockIn.getpackCountAll();
            //dGridslect.DataSource = bindingSourceselect;
            DcolumnSet.colSet(moduleInfo.materialList, dGridslect);
            comboBoxcustName.Text = GlobalInfo.address;
            textPnameQuery.Text = GlobalInfo.custPO;
            textBox1.Text = GlobalInfo.hetongNo;
            textBox2.Text = GlobalInfo.matName;
            textPnameQuery.Focus();
            //comboBoxcustName.Text = "";
        }

        private void dGridslect_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                pname = dGridslect.CurrentRow.Cells[field].Value.ToString();
                if (field != "")
                {
                    pname = dGridslect.CurrentRow.Cells[field].Value.ToString();
                }
                this.DialogResult = DialogResult.Yes;
            }
            catch (Exception)
            {
                MessageBox.Show("选择正确的名称");
            }
        }
    }
}
